/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web.servlet;

import com.google.gson.JsonObject;
import com.web.daoimpl.TestBiaoDaoImpl;
import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author liqianru
 */
@WebServlet("/admin_modifyStatus")
public class Admin_message extends HttpServlet {

    TestBiaoDaoImpl service=new TestBiaoDaoImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session=req.getSession(false);
        int count=0;
        int notestid=1;
        Enumeration attributenames=session.getAttributeNames();
        for(Enumeration e=attributenames;e.hasMoreElements();){
            String thisname=e.nextElement().toString();
           // System.out.println(thisname);
            if(thisname.equals("testid")){count++;break;}
            if(count!=0){break;}
        }
        //
        if(count!=0){
        if(req.getParameter("admin_action").equals("search_status")){
            int testid=(int)session.getAttribute("testid");
            int status=service.isStatusequal0(testid);
            resp.getWriter().print(status);

        }
        if(req.getParameter("admin_action").equals("modify_status")){
            int testid=(int)session.getAttribute("testid");
            int rows=0;
            rows=service.modify_status(testid);
            resp.getWriter().print(rows);
            System.out.println(rows);}
    }
        else{
            resp.getWriter().print(notestid);
        }
        
    }
    
}
